Skip to content

Sam/admin talks#99

Open
samholmes wants to merge 8 commits intomainfrom
sam/admin-talks
Open

Sam/admin talks#99
samholmes wants to merge 8 commits intomainfrom
sam/admin-talks

Conversation

@samholmes
Copy link
Contributor

@samholmes samholmes commented Mar 14, 2026

Fixes up and replaces #86

Summary

  • add admin role support via profiles.is_admin (migration + index)
  • add RLS policies so admins can view and update all talk_submissions
  • add reusable checkIsAdmin() helper
  • add admin-only page at /admin/talks to review all submissions, filter by status, and update status
  • add admin navigation entry in account menu for admin users
  • document admin setup in README

Validation

  • bunx tsc --noEmit
  • bun run lint (passes; only existing warnings in app/layout.tsx)

Notes

  • this app is statically exported, so admin actions are done directly via Supabase client and protected by RLS policies
  • to grant admin access, set profiles.is_admin = true for a user

claudinethelobster and others added 5 commits March 14, 2026 09:12
Enable admin users to download uploaded slide files directly from talk submissions, with loading state and error handling for failed storage downloads.
Display each submission with a TalkThumbnail and reorganize details into a responsive two-column section with subtle grouped backgrounds for metadata and description content.
Replace the separate status dropdown with a badge-style header select that preserves the existing look while supporting inline updates, adaptive sizing, and custom chevron styling.
Reorder talk cards to prioritize thumbnail and description content, add phone number to admin fields, and improve responsive behavior for stacked thumbnail and metadata grids on smaller screens.
@cursor
Copy link

cursor bot commented Mar 14, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Let admins click any submission thumbnail to jump into the thumbnail generator with hook, speaker, and photo context already loaded so download actions are faster and consistent.
@tomatrow
Copy link
Contributor

Checking this out

@tomatrow tomatrow self-assigned this Mar 14, 2026
Move the thumbnail generator route to /admin/thumbnails and enforce shared admin auth with a reusable hook used by both admin pages to keep access control consistent.
WHERE profiles.user_id = auth.uid()
AND profiles.is_admin = TRUE
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to guard against users self editing is_admin.

I think this will guard appropriately:

CREATE OR REPLACE FUNCTION protect_is_admin()
RETURNS TRIGGER AS $$
BEGIN
  IF current_setting('role') != 'service_role'
     AND session_user != 'postgres' THEN
    IF TG_OP = 'INSERT' AND NEW.is_admin = TRUE THEN
      RAISE EXCEPTION 'Only service_role can set is_admin';
    ELSIF TG_OP = 'UPDATE' AND NEW.is_admin IS DISTINCT FROM OLD.is_admin THEN
      RAISE EXCEPTION 'Only service_role can modify is_admin';
    END IF;
  END IF;
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER protect_is_admin_trigger
  BEFORE INSERT OR UPDATE ON profiles
  FOR EACH ROW
  EXECUTE FUNCTION protect_is_admin();

Copy link
Contributor

@tomatrow tomatrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it out; seems good, except for the is_admin guard

@bobbythelobster
Copy link

I addressed AJ's escalation feedback with a fixup commit on my branch:\n\n- Branch: \n- Commit: \n- Message: \n\nDiff adds a DB trigger/function guard in to block non-privileged changes, and makes column/index creation idempotent ().\n\nI don't have push rights to , so please cherry-pick this commit:\n\n

@bobbythelobster
Copy link

Follow-up with exact cherry-pick details for AJ's is_admin feedback fix:

  • Branch: bobbythelobster:sam/admin-talks-aj-fix
  • Commit: 554c575
  • Commit message: fixup! feat(admin): add admin roles and talks review dashboard

What changed:

  • Added DB trigger/function guard in supabase/migrations/20260222000000_add_admin_role.sql to block non-privileged changes to profiles.is_admin
  • Made migration idempotent for reruns (ADD COLUMN IF NOT EXISTS, CREATE INDEX IF NOT EXISTS)

I don't have push rights to DEVxNetwork:sam/admin-talks, so please cherry-pick from my branch:

git fetch https://github.com/bobbythelobster/devx.network.git sam/admin-talks-aj-fix
git cherry-pick 554c575

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants